import { EntitySchema } from '@mikro-orm/core';

export class ImsYzdKpAnnexOrder {
  id!: number;
  uniacid!: number;
  userId!: number;
  annexId!: number;
  ordercode!: string;
  outTradeNo!: string;
  totalPrice!: string;
  totalPayPrice!: string;
  sRemark?: unknown;
  submitTime!: string;
  isPay: boolean = false;
  payType?: number;
  payTime?: string;
  isSale: boolean = true;
  cancelState: boolean = false;
  saleState: boolean = false;
  cancelTime?: string;
  refundResult: boolean = false;
  refundState: boolean = false;
  refundContent?: unknown;
  refundImg?: unknown;
  autoCancelTime!: string;
  autoSalesTime!: string;
  isForm: boolean = false;
  courseId?: number;
  jsonData?: unknown;
  deviceType?: number;
  baidu?: unknown;
  payData?: unknown;
}

export const ImsYzdKpAnnexOrderSchema = new EntitySchema({
  class: ImsYzdKpAnnexOrder,
  properties: {
    id: { primary: true, type: 'number' },
    uniacid: { type: 'number' },
    userId: { type: 'number' },
    annexId: { type: 'number' },
    ordercode: { type: 'string', length: 255 },
    outTradeNo: { type: 'string', length: 255 },
    totalPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    totalPayPrice: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    sRemark: { type: 'unknown', columnType: 'longtext', nullable: true },
    submitTime: { type: 'string', length: 255 },
    isPay: { type: 'boolean', default: false },
    payType: { type: 'number', nullable: true },
    payTime: { type: 'string', length: 255, nullable: true },
    isSale: { type: 'boolean', default: true },
    cancelState: { type: 'boolean', default: false },
    saleState: { type: 'boolean', default: false },
    cancelTime: { type: 'string', length: 255, nullable: true },
    refundResult: { type: 'boolean', default: false },
    refundState: { type: 'boolean', default: false },
    refundContent: { type: 'unknown', columnType: 'longtext', nullable: true },
    refundImg: { type: 'unknown', columnType: 'longtext', nullable: true },
    autoCancelTime: { type: 'string', length: 255, default: '0' },
    autoSalesTime: { type: 'string', length: 255, default: '0' },
    isForm: { type: 'boolean', default: false },
    courseId: { type: 'number', nullable: true },
    jsonData: { type: 'unknown', columnType: 'longtext', nullable: true },
    deviceType: { type: 'number', fieldName: 'deviceType', nullable: true },
    baidu: { type: 'unknown', columnType: 'longtext', nullable: true },
    payData: {
      type: 'unknown',
      fieldName: 'payData',
      columnType: 'longtext',
      nullable: true,
    },
  },
});
